﻿<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vm="clr-namespace:WPFSearchDataGrid_Test"
    Title="MainWindow" Height="768" Width="1024" mc:Ignorable="d" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:my="clr-namespace:WPFSearchDataGrid_Test.Views" 
    xmlns:my1="clr-namespace:WPFSearchDataGrid;assembly=WPFSearchDataGrid">
    <Window.Resources>
        <CollectionViewSource x:Key="ViewSource" d:DesignSource="{d:DesignInstance my:ViewModel, CreateList=True}" />
        <CollectionViewSource x:Key="BusinessEntityAddresses" Source="{Binding Path=BusinessEntityAddresses, Source={StaticResource ViewSource}}" />
        <CollectionViewSource x:Key="Addresses" Source="{Binding Path=Addresses, Source={StaticResource ViewSource}}" />
    </Window.Resources>
    <Grid DataContext="{StaticResource BusinessEntityAddresses}">
        <Grid.RowDefinitions>
            <RowDefinition Height="52" />
            <RowDefinition Height="622*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <DataGrid AutoGenerateColumns="False" 
                  EnableRowVirtualization="True" 
                  EnableColumnVirtualization="True" 
                  Grid.Row="1" HorizontalAlignment="Stretch" 
                  ItemsSource="{Binding}" 
                  Name="DataGrid" 
                  RowDetailsVisibilityMode="VisibleWhenSelected" 
                  VerticalAlignment="Stretch">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="BusinessEntityIDColumn" Binding="{Binding Path=BusinessEntityID}" Header="BusinessEntityID" Width="100" />
                <DataGridTextColumn x:Name="AddressTypeIDColumn" Binding="{Binding Path=AddressTypeID}" Header="Address TypeID" Width="100" />
                <DataGridComboBoxColumn x:Name="AddressIDColumn" 
                                        Header="Address ID" 
                                        Width="150"  
                                        ItemsSource="{Binding Source={StaticResource Addresses}}" 
                                        DisplayMemberPath="AddressLine1"
                                        SelectedValuePath="AddressID"
                                        SelectedValueBinding="{Binding Path=AddressID,UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn x:Name="ModifiedDateColumn" Binding="{Binding Path=ModifiedDate}" Header="Modified Date" Width="100" />
            </DataGrid.Columns>
        </DataGrid>
        <my1:WPFSearchDataGrid  HorizontalAlignment="Stretch" 
                               Margin="0" 
                               Name="WWSearchDataGrid1" 
                               VerticalAlignment="Stretch" 
                               FilterChanged="WWSearchDataGrid1_OnFilterChanged"
                               DataContext="{Binding ElementName=DataGrid}" ShowHeader="Visible" ShowAdvanced="Visible" ShowRefresh="Visible" />
    </Grid>
</Window>
